// 基类图
<template>
  <div style="width:100%;height:100%">
    <div id="centerRTChart" style="width:100%;height:100%;"></div>
  </div>
</template>

<script>
import echartMixins from "@/utils/resizeMixins";
// 引入主题
import theme from '@/assets/js/purple'
export default {
  data() {
    return {
      chart: null
    };
  },
  mixins: [echartMixins],
  mounted() {
    this.draw();
  },
  methods: {
    draw() {
      // 基于准备好的dom，初始化echarts实例
      // [Vue warn]: Error in mounted hook;"TypeError: Cannot readl property'init' of undefined"
      // 版本问题，别用最新的5.0.0  
      this.$echarts.registerTheme('theme', theme);
      this.chart = this.$echarts.init(document.getElementById("centerRTChart"),theme);

      //  ----------------------------------------------------------------
      var option = {
    "animation": true,
    "animationThreshold": 2000,
    "animationDuration": 1000,
    "animationEasing": "cubicOut",
    "animationDelay": 0,
    "animationDurationUpdate": 300,
    "animationEasingUpdate": "cubicOut",
    "animationDelayUpdate": 0,
    "color": [
        "#c23531",
        "#2f4554",
        "#61a0a8",
        "#d48265",
        "#749f83",
        "#ca8622",
        "#bda29a",
        "#6e7074",
        "#546570",
        "#c4ccd3",
        "#f05b72",
        "#ef5b9c",
        "#f47920",
        "#905a3d",
        "#fab27b",
        "#2a5caa",
        "#444693",
        "#726930",
        "#b2d235",
        "#6d8346",
        "#ac6767",
        "#1d953f",
        "#6950a1",
        "#918597"
    ],
    "series": [
        {
            "type": "sankey",
            "data": [
                {
                    "name": "\u8d77\u70b9\u5317\u4eac"
                },
                {
                    "name": "\u8d77\u70b9\u4e0a\u6d77"
                },
                {
                    "name": "\u8d77\u70b9\u56db\u5ddd"
                },
                {
                    "name": "\u8d77\u70b9\u82cf\u5dde"
                },
                {
                    "name": "\u8d77\u70b9\u6d59\u6c5f"
                },
                {
                    "name": "\u8d77\u70b9\u5357\u4eac"
                },
                {
                    "name": "\u8d77\u70b9\u957f\u6c99"
                },
                {
                    "name": "\u8d77\u70b9\u94f6\u5ddd"
                },
                {
                    "name": "\u8d77\u70b9\u7ef5\u9633"
                },
                {
                    "name": "\u7ec8\u70b9\u82cf\u5dde"
                },
                {
                    "name": "\u7ec8\u70b9\u5317\u4eac"
                },
                {
                    "name": "\u7ec8\u70b9\u4e0a\u6d77"
                },
                {
                    "name": "\u7ec8\u70b9\u56db\u5ddd"
                },
                {
                    "name": "\u7ec8\u70b9\u5357\u4eac"
                },
                {
                    "name": "\u7ec8\u70b9\u6d59\u6c5f"
                },
                {
                    "name": "\u7ec8\u70b9\u957f\u6c99"
                },
                {
                    "name": "\u7ec8\u70b9\u94f6\u5ddd"
                },
                {
                    "name": "\u7ec8\u70b9\u7ef5\u9633"
                }
            ],
            "links": [
                {
                    "source": "\u8d77\u70b9\u5317\u4eac",
                    "target": "\u7ec8\u70b9\u56db\u5ddd",
                    "value": 12
                },
                {
                    "source": "\u8d77\u70b9\u5317\u4eac",
                    "target": "\u7ec8\u70b9\u4e0a\u6d77",
                    "value": 6
                },
                {
                    "source": "\u8d77\u70b9\u4e0a\u6d77",
                    "target": "\u7ec8\u70b9\u56db\u5ddd",
                    "value": 12
                },
                {
                    "source": "\u8d77\u70b9\u56db\u5ddd",
                    "target": "\u7ec8\u70b9\u82cf\u5dde",
                    "value": 15
                },
                {
                    "source": "\u8d77\u70b9\u56db\u5ddd",
                    "target": "\u7ec8\u70b9\u56db\u5ddd",
                    "value": 14
                },
                {
                    "source": "\u8d77\u70b9\u56db\u5ddd",
                    "target": "\u7ec8\u70b9\u6d59\u6c5f",
                    "value": 5
                },
                {
                    "source": "\u8d77\u70b9\u4e0a\u6d77",
                    "target": "\u7ec8\u70b9\u5317\u4eac",
                    "value": 22
                },
                {
                    "source": "\u8d77\u70b9\u5317\u4eac",
                    "target": "\u7ec8\u70b9\u5317\u4eac",
                    "value": 11
                },
                {
                    "source": "\u8d77\u70b9\u82cf\u5dde",
                    "target": "\u7ec8\u70b9\u4e0a\u6d77",
                    "value": 14
                },
                {
                    "source": "\u8d77\u70b9\u82cf\u5dde",
                    "target": "\u7ec8\u70b9\u5317\u4eac",
                    "value": 1
                },
                {
                    "source": "\u8d77\u70b9\u6d59\u6c5f",
                    "target": "\u7ec8\u70b9\u82cf\u5dde",
                    "value": 4
                },
                {
                    "source": "\u8d77\u70b9\u5357\u4eac",
                    "target": "\u7ec8\u70b9\u6d59\u6c5f",
                    "value": 28
                },
                {
                    "source": "\u8d77\u70b9\u6d59\u6c5f",
                    "target": "\u7ec8\u70b9\u5357\u4eac",
                    "value": 23
                },
                {
                    "source": "\u8d77\u70b9\u957f\u6c99",
                    "target": "\u7ec8\u70b9\u82cf\u5dde",
                    "value": 23
                },
                {
                    "source": "\u8d77\u70b9\u94f6\u5ddd",
                    "target": "\u7ec8\u70b9\u5317\u4eac",
                    "value": 1
                },
                {
                    "source": "\u8d77\u70b9\u6d59\u6c5f",
                    "target": "\u7ec8\u70b9\u7ef5\u9633",
                    "value": 26
                },
                {
                    "source": "\u8d77\u70b9\u7ef5\u9633",
                    "target": "\u7ec8\u70b9\u957f\u6c99",
                    "value": 3
                },
                {
                    "source": "\u8d77\u70b9\u94f6\u5ddd",
                    "target": "\u7ec8\u70b9\u4e0a\u6d77",
                    "value": 20
                }
            ],
            "left": "5%",
            "top": "5%",
            "right": "20%",
            "bottom": "5%",
            "nodeWidth": 20,
            "nodeGap": 8,
            "nodeAlign": "justify",
            "layoutIteration": 32,
            "orient": "horizontal",
            "draggable": true,
            "focusNodeAdjacency": false,
            "label": {
                "show": true,
                "position": "right",
                "margin": 8
            },
            "lineStyle": {
                "show": true,
                "width": 1,
                "opacity": 0.2,
                "curveness": 0.5,
                "type": "solid",
                "color": "source"
            },
            "itemStyle": {
                "borderColor": "#fff",
                "borderWidth": 1
            }
        }
    ],
    "legend": [
        {
            "data": [
                ""
            ],
            "selected": {
                "": true
            },
            "show": true,
            "padding": 5,
            "itemGap": 10,
            "itemWidth": 25,
            "itemHeight": 14
        }
    ],
    "tooltip": {
        "show": true,
        "trigger": "item",
        "triggerOn": "mousemove|click",
        "axisPointer": {
            "type": "line"
        },
        "showContent": true,
        "alwaysShowContent": false,
        "showDelay": 0,
        "hideDelay": 100,
        "textStyle": {
            "fontSize": 14
        },
        "borderWidth": 0,
        "padding": 5
    },
    // "title": [
    //     {
    //         "text": "\u4eba\u5458\u6d41\u5411",
    //         "padding": 5,
    //         "itemGap": 10
    //     }
    // ]
      };

      this.chart.setOption(option);
    }
  },
  destroyed() {
    window.onresize = null;
  }
};
</script>

<style lang="scss" scoped>
</style>